//home模块的小仓库
import { reqCategoryList, reqFloorList } from "@/api";
import { reqGetBannerList } from "@/api";

const state={categoryList:[],BannerList:[],floorList:[]};
const actions={
  //通过API里面的接口函数调用，向服务器发请求，获取服务器的数据
 async categoryList(context){
   const result=  await reqCategoryList();
    if(result.code==200){
      context.commit('CATEGORYLIST',result.data)
    }
  },
  async getBannerList(context){
    const result= await reqGetBannerList()
    
    if(result.code==200){
      
      context.commit('GETBANNERLIST',result.data)
    }
  },
  async getFloorList(context){
    const result = await reqFloorList()

    if(result.code==200){
      context.commit('GETFLOORLIST',result.data)
    }
  }
};
const mutations={
  CATEGORYLIST(state,categoryList)
  {
    state.categoryList=categoryList

  },
  GETBANNERLIST(state,BannerList){
    
    state.BannerList=BannerList

  },
  GETFLOORLIST(state,floorList){
    state.floorList=floorList
  }
};
const getters={};
export default{
  state,
  mutations,
  actions,
  getters
}